<?php

namespace app\api\controller\hotel;


use app\common\controller\Api;
use think\Hook;

/**
 * 获取数据
 */
class Token extends Api
{
    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    
    protected $appid = 'ee4e648231c8448fb1c71e9308512861';
    
    protected $accessid = '1962a00cd74e4375a2454e4877b4c30b';
    
    protected $response_type = 'token';



    public function getToken(){
        $token = cache('token');
       
        if($token){
            return  $token;
        }        
       
        $url = 'https://cysms.wuuxiang.com/api/auth/accesstoken';
        $data = ['appid'=>$this->appid,'accessid'=>$this->accessid,'response_type'=>$this->response_type];   
        $response = httpCurlpost($url,$data);
        $result = json_decode($response,true);
        if($result['code'] == 0){
            cache('token',$result['access_token'],$result['expires_in']);
        }else{
            return false;
        }
        return $result['access_token'];
    }
    
   
       

    
}